<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('getfile','',0);
pc_base::load_app_func('util','content');
class index extends admin {
    function __construct() {
        parent::__construct();
    }
    public function init() {
        include $this->admin_tpl('webman');
    }

/*后台留言管理*/
    public function liuyan(){
        $this->liuyan=pc_base::load_model('liuyan_model');
        $data=$this->liuyan->select();
        include $this->admin_tpl('liuyan');
    }
    /*删除留言*/
    public function liuyan_del(){
        $this->liuyan=pc_base::load_model('liuyan_model');
        $id=$_POST['id'];
        if($this->liuyan->delete("id=$id")){
            echo "ok";
        }else{
            echo "fail";
        }
    }


    /*电话号码管理*/
    public function tel_list(){
        $this->tel=pc_base::load_model('tel_model');
        $data=$this->tel->select();
        include $this->admin_tpl('tel_list');
    }
    public function tel_delete(){
        $this->tel=pc_base::load_model('tel_model');
        $id=$_POST['id'];
        if($this->tel->delete("id=$id")){
            exit('ok');
        }else{
            exit('fail');
        }
        include $this->admin_tpl('tel_list');
    }

     public function tel_add(){
         if($_POST){
             $this->tel=pc_base::load_model('tel_model');
             if($_POST['name']==''){
                exit('请输入名称');
            }
             if($_POST['number']==''){
                 exit('请输入号码');
             }
             $data['name']=$_POST['name'];
             $data['number']=$_POST['number'];
             $data['beizhu']=$_POST['beizhu'];
             if($this->tel->insert($data)){
                 exit('ok');
             }else{
                 exit('fail');
             }


         }
         include $this->admin_tpl('tel_add');
     }
    public function tel_edit(){
        $id=$_POST['id'];
        $this->tel=pc_base::load_model('tel_model');
        if($_POST['act']){
            if($_POST['name']==''){
                exit('名称不能为空');
            }
            if($_POST['number']==''){
                exit('号码不能为空');
            }
            $data['name']=$_POST['name'];
            $data['number']=$_POST['number'];
            $data['beizhu']=$_POST['beizhu'];
            if($this->tel->update($data,"id=$_POST[id]")){
                exit('ok');
            }else{
                exit('fail');
            };
        }
        $data=$this->tel->get_one("id=$id");
        include $this->admin_tpl('tel_edit');
    }

}



?>